
//
//  YSCommonBussinessFlowListController.m
//  YaSha-iOS
//
//  Created by 罗罗诺亚索隆 on 2018/10/15.
//  Copyright © 2018年 亚厦装饰股份有限公司. All rights reserved.
//

#import "YSCommonBussinessFlowListController.h"
#import "YSFlowRecordListCell.h"
#import "UIView+Extension.h"
#import "LCSelectMenuView.h"
#import "YSContactModel.h"
#import "YSFlowAssociatedViewController.h"
#import "YSFlowDocumentationViewController.h"
#import "YSFlowMapViewController.h"



@interface YSCommonBussinessFlowListController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic,strong) UIButton *footButton;
@property (nonatomic,assign) BOOL scrollFlag; //手动滚动标志，防止点击菜单滚动触发didScroll代理方法造成菜单定位死循环
@property (nonatomic,strong) NSMutableArray *sectionLocationHeaderArray;


@end

@implementation YSCommonBussinessFlowListController
- (NSMutableArray *)fileArray {
    if (!_fileArray) {
        _fileArray = [NSMutableArray array];
    }
    return _fileArray;
}
# pragma mark -- 懒加载
- (NSMutableArray *)attachArray {
    if (!_attachArray) {
        _attachArray = [NSMutableArray array];
    }
    return _attachArray;
}
- (NSMutableArray *)documentAr {
    if (!_documentAr) {
        _documentAr = [NSMutableArray array];
    }
    return _documentAr;
}
- (UIView *)navView {
    if (!_navView) {
        _navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kSCREEN_WIDTH, kTopHeight)];
        [_navView setGradientBackgroundWithColors:@[kUIColor(84, 106, 253, 1),kUIColor(46, 193, 255, 1)] locations:nil startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
        UIButton *btn = [[UIButton alloc]init];
        btn.frame = CGRectMake(10*kWidthScale, 2*kHeightScale+kStatusBarHeight, 28*kWidthScale, 38*kHeightScale);
        [btn setImage:[UIImage imageNamed:@"返回白"] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        [_navView addSubview:btn];
        
        UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(90*kWidthScale, kStatusBarHeight+11*kHeightScale, 195*kWidthScale, 22*kHeightScale)];
        titleLabel.text = @"流程详情";
        titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:18];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.textColor = [UIColor whiteColor];
        [_navView addSubview:titleLabel];
    }
    return _navView;
}

- (LCSelectMenuView *)selectMenu{
    if (!_selectMenu) {
        _selectMenu = [LCSelectMenuView new];
        _selectMenu.alpha = 0;
        _selectMenu.frame = CGRectMake(0, kTopHeight, SCREEN_WIDTH, 44*kHeightScale);
        _selectMenu.titleArray = @[@"申请表单",@"附言记录",@"处理记录",@"转阅记录"];
        __weak typeof(self) _ws = self;
        [_selectMenu setPageSelectBlock:^(NSInteger index) {
            _ws.scrollFlag = YES;
            CGRect rect = [_ws.tableView rectForSection:index-1];
            CGFloat offsetY = rect.origin.y -44*kHeightScale;
            [_ws.tableView setContentOffset:CGPointMake(0, offsetY) animated:YES];
        }];
    }
    return _selectMenu;
}
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kTopHeight, kSCREEN_WIDTH, kSCREEN_HEIGHT-kTopHeight-kBottomHeight - 50*kHeightScale) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = [UIColor whiteColor];
        _tableView.bounces = NO;
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
        self.functionHeaderView = [[YSFlowDetailsHeaderView alloc]init];
        [self.functionHeaderView.flowButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
        [self.functionHeaderView.documentButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
        [self.functionHeaderView.chartButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
        _tableView.tableHeaderView = self.functionHeaderView;
        [_tableView addSubview:self.selectMenu];
        
    }
    return _tableView;
}
- (NSMutableArray *)sectionLocationHeaderArray{
    if (!_sectionLocationHeaderArray) {
        _sectionLocationHeaderArray = [NSMutableArray array];
    }
    return _sectionLocationHeaderArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataSourceArray = [NSMutableArray array];
    self.recordArray = [NSMutableArray array];
    self.postscriptArray = [NSMutableArray array];
    self.turnArray = [NSMutableArray array];
    [self.view addSubview:self.tableView];
    [self.view addSubview:self.navView];
    self.coverNavView = [[YSFlowDetailsConerNavView alloc]init];
    self.coverNavView.alpha = 0;
    [self.coverNavView.flowButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
    [self.coverNavView.documentButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
    [self.coverNavView.chartButton addTarget:self action:@selector(jumpView:) forControlEvents:UIControlEventTouchUpInside];
    [self.coverNavView.backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.coverNavView];
    _flowFormBottomView = [[YSFlowFormBottomView alloc] init];
    [_flowFormBottomView setCellModel:_cellModel withFlowType:_flowType];
    [self.view addSubview:_flowFormBottomView];
    [_flowFormBottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-kBottomHeight);
        make.height.mas_equalTo(50*kHeightScale);
    }];
    
    [self checkTrans];
    [self monitorAction];
    //监听历程处理通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateFlowStatus:) name:@"PostUpdateFlowStatus" object:nil];
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:NO];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
}

-(void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

# pragma mark -- 设置状态栏颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
#pragma mark -- 返回上一页
- (void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

# pragma mark -- 视图跳转
- (void)jumpView:(UIButton *)btn {
    if (btn.tag == 10) {
        if (self.associaterArr.count > 0) {
            YSFlowAssociatedViewController *associatedViewController = [[YSFlowAssociatedViewController alloc]init];
            associatedViewController.businessKey = self.cellModel.businessKey;
            associatedViewController.dataSourceArray = [self.associaterArr mutableCopy];
            [self.navigationController pushViewController:associatedViewController animated:YES];
        }else {
            [QMUITips showInfo:@"暂无关联流程" inView:self.view hideAfterDelay:1.5];
        }
    }else if (btn.tag == 20){
        if (self.attachArray.count > 0) {
            YSFlowDocumentationViewController *flowAttachPageController = [[YSFlowDocumentationViewController alloc] init];
            
            flowAttachPageController.attachArray =self.attachArray;
            flowAttachPageController.businessKey = self.cellModel.businessKey;
            [self.navigationController pushViewController:flowAttachPageController animated:YES];
        }else{
            [QMUITips showInfo:@"暂无关联文档" inView:self.view hideAfterDelay:1.5];
        }
        
    }else if (btn.tag == 30){
        YSFlowMapViewController *flowMapViewController = [[YSFlowMapViewController alloc] init];
        flowMapViewController.urlString = [NSString stringWithFormat:@"%@%@/%@", YSDomain, getApplyMapByIdForMobileApi, self.cellModel.processInstanceId];
        [self.navigationController pushViewController:flowMapViewController animated:YES];
    }
}


#pragma mark - 流程状态改变通知
- (void)updateFlowStatus:(NSNotification *)notification {
    NSDictionary *handleDic = notification.userInfo;
    NSUInteger flowHandleType = [handleDic[@"flowHandleType"] integerValue];
    if (flowHandleType == FlowHandleTypeTrans) {//转阅要回到详情页，暂时只需要提示
        [QMUITips showSucceed:@"流程转阅成功" inView:self.view hideAfterDelay:1];
    }
}
/** 如果是他人转阅的流程，查看时不可操作，并且调用流程处理接口返回时并删除该条数据，知会节点时，点击待办进入详情页会调用流程处理<做审批处理>接口，待办列表消失
 */
- (void)checkTrans {
    if (_flowType == YSFlowTypeTodo) {
        if (_cellModel.turnRead) {
            [_flowFormBottomView removeFromSuperview];
            self.tableView.frame = CGRectMake(0, 0, kSCREEN_WIDTH, kSCREEN_HEIGHT-(kTopHeight+40) - kBottomHeight);//移除
            NSString *urlString = [NSString stringWithFormat:@"%@%@/%lu", YSDomain, flowProcessApi, FlowHandleTypeTurnRead+1];
            NSDictionary *payload = @{
                                      @"message": @"",
                                      @"taskId": _cellModel.taskId,
                                      @"userIds": @[],
                                      @"processInstanceId": _cellModel.processInstanceId
                                      };
            [YSNetManager ys_request_POSTWithUrlString:urlString isNeedCache:NO parameters:payload successBlock:^(id response) {
                if ([response[@"code"] intValue] == 1) {
                    NSDictionary *handleDic = @{
                                                @"flowType": [NSString stringWithFormat:@"%zd", _flowType],
                                                @"flowHandleType": [NSString stringWithFormat:@"%zd", FlowHandleTypeTurnRead],
                                                @"model": _cellModel
                                                };
                    //转阅已读  发通知改变状态
                    _cellModel.turnRead ? [[NSNotificationCenter defaultCenter] postNotificationName:@"PostUpdateFlowStatus" object:nil userInfo:handleDic] : nil;
                }
            } failureBlock:^(NSError *error) {
                
            } progress:nil];
        }
        if ([_cellModel.taskType isEqualToString:FlowTaskZH]) {
            //       [_flowFormBottomView removeFromSuperview];
            //        self.tableView.frame = CGRectMake(0, 0, kSCREEN_WIDTH, kSCREEN_HEIGHT-(kTopHeight+40) - kBottomHeight);//移除
            NSString *urlString = [NSString stringWithFormat:@"%@%@/%lu", YSDomain, flowProcessApi, FlowHandleTypeApproval+1];
            NSDictionary *payload = @{
                                      @"message": @"",
                                      @"taskId": _cellModel.taskId,
                                      @"userIds": @[],
                                      @"processInstanceId": _cellModel.processInstanceId
                                      };
            [YSNetManager ys_request_POSTWithUrlString:urlString isNeedCache:NO parameters:payload successBlock:^(id response) {
                if ([response[@"code"] intValue] == 1) {
                    NSDictionary *handleDic = @{
                                                @"flowType": [NSString stringWithFormat:@"%zd", _flowType],
                                                @"flowHandleType": [NSString stringWithFormat:@"%zd", FlowHandleTypeApproval],
                                                @"model": _cellModel
                                                };
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"PostUpdateFlowStatus" object:nil userInfo:handleDic];
                }
            } failureBlock:^(NSError *error) {
                
            } progress:nil];
        }
    }
    
}
# pragma mark -- tableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return self.dataSourceArray.count;
    }else if (section == 1){
        return self.postscriptArray.count;
    }else if (section == 2){
        return self.recordArray.count;
    }else if (section == 3){
        return self.turnArray.count > 3 ?  3:self.turnArray.count;
    }else{
        return 0;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return 0.01;
    }else{
        return 42*kHeightScale;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
   if (section == 3 && self.turnArray.count > 0) {
        return 42*kHeightScale;
    }else{
        return 0.01;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    if (section == 3) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor whiteColor];
        self.footButton = [UIButton buttonWithType:UIButtonTypeCustom];
        if (self.turnArray.count <= 3) {
            self.footButton.selected = YES;
            self.footButton.userInteractionEnabled = NO;
        }else{
            self.footButton.selected = NO;
            self.footButton.userInteractionEnabled = YES;
        }
        [self.footButton setTitle:@"查看全部" forState:UIControlStateNormal];
        [self.footButton setTitleColor:kUIColor(0, 122, 255, 1) forState:UIControlStateNormal];
        [self.footButton setTitle:@"没有更多了" forState:UIControlStateSelected];
        [self.footButton setTitleColor:kGrayColor(204) forState:UIControlStateSelected];
        [self.footButton addTarget:self action:@selector(showMore) forControlEvents:UIControlEventTouchUpInside];
        [view addSubview:self.footButton];
       if (section == 3 && self.turnArray.count > 0) {
            [self.footButton mas_updateConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
        }else{
            [self.footButton mas_makeConstraints:^(MASConstraintMaker *make) {
                make.size.mas_equalTo(CGSizeMake(0, 0));
            }];
        }
        return view;
    }else{
        return nil;
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (section == 0) {
        return nil;
    }else{
        NSArray *titleArray = @[@"提交者附言",@"处理记录",@"转阅记录"];
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor colorWithRed:243/255.0 green:244/255.0 blue:245/255.0 alpha:1];
        UILabel *label = [[UILabel alloc]init];
        label.font = [UIFont systemFontOfSize:12];
        label.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1];
        if (section == 1) {
            label.text = [NSString stringWithFormat:@"%@(%lu)",titleArray[section-1],(unsigned long)self.postscriptArray.count];
        }else if (section == 2) {
            label.text = [NSString stringWithFormat:@"%@(%lu)",titleArray[section-1],(unsigned long)self.recordArray.count];
        }else if (section == 3){
            label.text = [NSString stringWithFormat:@"%@(%lu)",titleArray[section-1],(unsigned long)self.turnArray.count];
        }else {
            label.text = titleArray[section];
        }
        [view addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(view.mas_top).offset(8);
            make.left.mas_equalTo(view.mas_left).offset(16);
            make.bottom.mas_equalTo(view.mas_bottom).offset(-8);
            make.right.mas_equalTo(view.mas_right).offset(-16);
        }];
        return view;
    }
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 10*kHeightScale;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return UITableViewAutomaticDimension;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
- (void)callPhone:(NSString *)userId andTableViewCell:(YSFlowRecordListCell *) cell {
    YSWeak;
    [[cell.callButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        RLMResults *results = [YSContactModel objectsWhere:[NSString stringWithFormat:@"userId = '%@'AND isOrg = NO AND delFlag = '1' AND postStatus = '1' AND status = '1' AND isPublic != '0'", userId]];
        //点击立即联系，直接拨打人员信息中的手机字段号码，不需确认，点击一次即呼出。
        //若人员的手机字段号码为空，则默认拨打座机号码字段内容，不需确认，点击一次即呼出。
        //若上述两个字段内容均为空，则提示暂无可用号码（参考设计样式）
        if (results.count != 0) {
            YSContactModel *contactModel = results[0];
            if (contactModel.mobile.length) {
                [YSUtility openUrlWithType:YSOpenUrlCall urlString:contactModel.mobile];
            }else if (contactModel.phone.length) {
                [YSUtility openUrlWithType:YSOpenUrlCall urlString:contactModel.phone];
            }else{
                [QMUITips showError:@"暂无可用号码" inView:weakSelf.view hideAfterDelay:1.0];
            }
        } else {
            [QMUITips showError:@"暂无可用号码" inView:weakSelf.view hideAfterDelay:1.0];
        }
    }];
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    self.scrollFlag = NO;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    CGFloat offsetY = scrollView.contentOffset.y;
    if (offsetY <= 0) {
        self.coverNavView.alpha = 0;
    }else{
        //悬浮菜单
        [self hangOnMenu:offsetY];
        //菜单联动
        [self updateMenuTitle:offsetY];
    }
}

/**
 联动过程步骤title
 */
- (void)updateMenuTitle:(CGFloat)contentOffsetY{
    if(!_scrollFlag){
        //遍历
        for (int i = 0; i<self.sectionLocationHeaderArray.count; i++) {
            //最后一个按钮
            if (i == self.sectionLocationHeaderArray.count - 1) {
                if (contentOffsetY >= [self.sectionLocationHeaderArray[i] floatValue]) {
                    [self.selectMenu setCurrentPage:i];
                }
            }else{
                if (contentOffsetY >= [self.sectionLocationHeaderArray[i] floatValue] && contentOffsetY < [self.sectionLocationHeaderArray[i+1] floatValue]) {
                    [self.selectMenu setCurrentPage:i];
                }
            }
        }
    }
}


- (void)markSectionHeaderLocation{
    
    self.sectionLocationHeaderArray = nil;
    //计算对应每个分组头的位置
    for (int i = 0; i < self.selectMenu.titleArray.count; i++) {
        
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:i];
        CGRect headerFrame = [self.tableView rectForHeaderInSection:indexPath.section];
        //第一组的偏移量比其他组少10
        //        CGFloat offsetHeaderY = (headerFrame.origin.y+10*(i+1)+kTopHeight+44*kHeightScale);
        CGFloat offsetHeaderY = (headerFrame.origin.y-kTopHeight);
        NSLog(@"offsetFootY is %f",offsetHeaderY);
        [self.sectionLocationHeaderArray addObject:[NSNumber numberWithFloat:offsetHeaderY]];
    }
}

- (void)hangOnMenu:(CGFloat)offsetY{
    NSLog(@"=========%f",offsetY);
    if (offsetY > 130) {
        //防止多次更改页面层级
        if ([self.selectMenu.superview isEqual:self.view]) {
            self.functionHeaderView.alpha = 0;
            self.navView.alpha = 0;
            self.coverNavView.alpha = 1;
            self.selectMenu.alpha = 1;
            return;
        }
        //加载到view上
        self.selectMenu.frame = CGRectMake(0, kTopHeight, SCREEN_WIDTH, 44*kHeightScale);
        
        [self.selectMenu  setGradientBackgroundWithColors:@[kUIColor(84, 106, 253, 1),kUIColor(46, 193, 255, 1)] locations:nil startPoint:CGPointMake(0, 0) endPoint:CGPointMake(1, 0)];
        [self.view addSubview:self.selectMenu];
    }else{
        self.functionHeaderView.alpha = 1;
        self.navView.alpha = 1;
        self.coverNavView.alpha = 0;
        self.selectMenu.alpha = 0;
    }
}

- (void)showMore {
    
}
/** 处理/转阅 */
- (void)monitorAction {
    YSWeak;
    [_flowFormBottomView.sendActionSubject subscribeNext:^(UIButton *button) {
        YSStrong;
        YSFlowHandleViewController *flowHandleViewController = [[YSFlowHandleViewController alloc] init];
        flowHandleViewController.cellModel = strongSelf.cellModel;
        if (button.tag == 0) {
            QMUIAlertAction *action0 = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleDestructive handler:^(QMUIAlertAction *action) {
                
            }];
            QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"审批" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeApproval;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"驳回" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeReject;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            QMUIAlertAction *action3 = [QMUIAlertAction actionWithTitle:@"审批并加签" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeAdd;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            QMUIAlertAction *action4 = [QMUIAlertAction actionWithTitle:@"转办" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeChange;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            QMUIAlertAction *action5 = [QMUIAlertAction actionWithTitle:@"暂存" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeSave;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            QMUIAlertAction *action6 = [QMUIAlertAction actionWithTitle:@"评审" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = FlowHandleTypeReview;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            
            QMUIAlertAction *action7 = [QMUIAlertAction actionWithTitle:@"协同" style:QMUIAlertActionStyleDefault handler:^(QMUIAlertAction *action) {
                flowHandleViewController.flowHandleType = YSFlowHandleTypeSynergy;
                [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            }];
            
            QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
            
            [alertController addAction:action0];
            
            if( [strongSelf.cellModel.taskType isEqualToString:FlowTaskPS]){
                [alertController addAction:action6];
            }else if([strongSelf.cellModel.taskType isEqualToString:FlowTaskXT]){
                [alertController addAction:action7];
            }else{
                [alertController addAction:action1];
                [alertController addAction:action2];
                [alertController addAction:action3];
            }
            
            [alertController addAction:action4];
            [alertController addAction:action5];
            [alertController showWithAnimated:YES];
        } else if (button.tag == 2) {
            flowHandleViewController.flowHandleType = FlowHandleTypeRevoke;
            [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
        } else {
            flowHandleViewController.flowHandleType = FlowHandleTypeTrans;
            [strongSelf.navigationController pushViewController:flowHandleViewController animated:YES];
            
        }
    }];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
















